/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package org.vale.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Gabriel Bran gbran.u@gmail.com
 */
@Entity
@Table(name = "evaluation_form")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "EvaluationForm.findAll", query = "SELECT e FROM EvaluationForm e"),
    @NamedQuery(name = "EvaluationForm.findByIdEvform", query = "SELECT e FROM EvaluationForm e WHERE e.idEvform = :idEvform"),
    @NamedQuery(name = "EvaluationForm.findByAnswer", query = "SELECT e FROM EvaluationForm e WHERE e.answer = :answer")})
public class EvaluationForm implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_evform")
    private Integer idEvform;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "answer")
    private String answer;
    @JoinColumn(name = "id_question", referencedColumnName = "id_question")
    @ManyToOne(optional = false)
    private FormQuestion idQuestion;
    @JoinColumn(name = "id_eva", referencedColumnName = "id_eva")
    @ManyToOne(optional = false)
    private Evaluation idEva;

    public EvaluationForm() {
    }

    public EvaluationForm(Integer idEvform) {
        this.idEvform = idEvform;
    }

    public EvaluationForm(Integer idEvform, String answer) {
        this.idEvform = idEvform;
        this.answer = answer;
    }

    public Integer getIdEvform() {
        return idEvform;
    }

    public void setIdEvform(Integer idEvform) {
        this.idEvform = idEvform;
    }

    public String getAnswer() {
        return answer;
    }

    public void setAnswer(String answer) {
        this.answer = answer;
    }

    public FormQuestion getIdQuestion() {
        return idQuestion;
    }

    public void setIdQuestion(FormQuestion idQuestion) {
        this.idQuestion = idQuestion;
    }

    public Evaluation getIdEva() {
        return idEva;
    }

    public void setIdEva(Evaluation idEva) {
        this.idEva = idEva;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idEvform != null ? idEvform.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof EvaluationForm)) {
            return false;
        }
        EvaluationForm other = (EvaluationForm) object;
        if ((this.idEvform == null && other.idEvform != null) || (this.idEvform != null && !this.idEvform.equals(other.idEvform))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.vale.entity.EvaluationForm[ idEvform=" + idEvform + " ]";
    }
    
}
